package com.slz3.business.module.systemManagement.sysMenu.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class SysMenuFactory {

    /**
     * 初始化基础属性值
     */
    public static SysMenu initBaseFields(SysMenu sysMenu) {
        if (sysMenu.getUuid() == null) {
            sysMenu.setUuid(UUIDUtils.generateUUID());
            sysMenu.setCreateTime(LocalDateTime.now());
            sysMenu.setSerAudit(AuditFlag.APPROVED);
            if (VE.isEmpty(sysMenu.getSerUsing())) {
                sysMenu.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            sysMenu.setLastModifyTime(LocalDateTime.now());
        }
        return sysMenu;
    }

    /**
     * 初始化基础属性值
     */
    public static SysMenu initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static SysMenu newTemStyle() {
        return new SysMenu();
    }

}
